// +build go1.7

package errors

import (
	"fmt"
	"runtime"
	"strings"
)

func getCallers(pcs []uintptr) string {
	var (
		invalid bool
		callers string
	)
	frames := runtime.CallersFrames(pcs)
	for {
		f, more := frames.Next()
		index := strings.Index(f.File, "xp/")
		if index > 0 {
			invalid = false
			for _, ignore := range ignorePrefix {
				if strings.HasPrefix(f.File[index+4:], ignore) {
					invalid = true
					break
				}
			}
			if invalid {
				continue
			}
			if callers != "" {
				callers += ","
			}
			callers += fmt.Sprintf("%s:%d", f.File[index+4:], f.Line)
		}
		if !more {
			break
		}
	}
	return callers
}
